package com.ymatou.iapi.productmanager.testcase;

import com.ymttest.business.service.ProductManagerCallServiceV3;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.gson.JsonObject;
import com.ymatou.iapi.productmanager.parameter.PunishSellerOperationBean;
import com.ymatou.iapi.productmanager.parameter.product.AddSellerProductRequest;
import com.ymatou.iapi.productmanager.service.PunishSellerOperationCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.ProductManagerCallServiceV2;
import com.ymttest.utils.EnvSetup;
/**
*买手处罚品牌禁售下架商品(MQ回调)Test
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_PunishSellerOperation{
	private static PunishSellerOperationBean punishselleroperationBean;
	private static PunishSellerOperationCall punishselleroperationCall;
	private static int sellerId = Integer.parseInt(EnvSetup.getData("productsellerid"));
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("买手处罚品牌禁售下架商品(MQ回调)Test");
	}

	@Before
	public void caseUp() {
		punishselleroperationBean=new PunishSellerOperationBean();
		punishselleroperationCall=new PunishSellerOperationCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(punishselleroperationCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_PunishSellerOperation_001() {
		//wuwen 20200111 实际添加商品对禁售已经控制了，所以case无法进行到GetProductListByProductIdList接口
		Logger.start(true,"对一个买手进行品牌禁售，会进行下架 成功(20200111 需要研发排查)");
		try {
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId) ;
			addpro.getProduct().setBrandName("jinyong");
			addpro.getProduct().setBrandId(16666);
		//	String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			Thread.sleep(1000);
			JsonObject before = ProductManagerCallServiceV2.GetProductListByProductIdList(productId);
			punishselleroperationBean.setSellerId(sellerId);
			punishselleroperationBean.setPunishType(18);
			punishselleroperationBean.setExtend1("jinyong");
			punishselleroperationCall.setData(punishselleroperationBean);
			punishselleroperationCall.callService();		
			JsonObject after = ProductManagerCallServiceV2.GetProductListByProductIdList(productId);
			Logger.verifyNotEquals(before.get("Status").getAsInt(), after.get("Status").getAsInt(), "验证状态变更了");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
}